---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: metadata-service-account
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: pl-vizier-metadata
rules:
- apiGroups:
  - ""
  resources:
  - pods
  - services
  - endpoints
  - namespaces
  verbs:
  - "watch"
  - "get"
  - "list"
- apiGroups:
  - apps
  resources:
  - replicasets
  - deployments
  verbs:
  - watch
  - get
  - list
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: pl-vizier-metadata-cluster-binding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: pl-vizier-metadata
subjects:
- kind: ServiceAccount
  name: metadata-service-account
  namespace: pl
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: pl-vizier-metadata-node-view-cluster-binding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: pl-node-view
subjects:
- kind: ServiceAccount
  name: metadata-service-account
  namespace: pl
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: pl-vizier-crd-metadata-binding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: pl-vizier-crd-role
subjects:
- kind: ServiceAccount
  name: metadata-service-account
  namespace: pl
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: pl-vizier-metadata-role
rules:
- apiGroups:
  - ""
  resources:
  - endpoints
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - coordination.k8s.io
  resources:
  - leases
  verbs:
  - create
- apiGroups:
  - coordination.k8s.io
  resources:
  - leases
  resourceNames:
  - metadata-election
  verbs:
  - get
  - update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: pl-vizier-metadata-binding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: pl-vizier-metadata-role
subjects:
- kind: ServiceAccount
  name: metadata-service-account
  namespace: pl
